<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Notepad</title>

  <!-- bootstrap -->
  <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />

  <!-- animate.css -->
  <link rel="stylesheet" href="./assets/css/animate.min.css" />

  <!-- mui -->
  <link rel="stylesheet/less" href="./assets/plugins/mui/css/mui.min.css" />

  <!-- city-picker -->
  <link rel="stylesheet" href="./assets/plugins/city-picker/city-picker.css" />

  <!-- 重置样式 -->
  <link rel="stylesheet/less" href="./assets/css/reset.less" />

  <!-- 公共样式 -->
  <link rel="stylesheet/less" href="./assets/css/common.less" />

  <!-- 页面独立的 -->
  <link rel="stylesheet/less" href="./assets/css/UserProfile.less" />
</head>

<body>
  <div class="user user-addtype">
    <h2><strong>分页录入</strong></h2>
    <h3>您可在本页录入您的分类信息，录入成功后将在首页展示您的卡片</h3>
  </div>

  <form class="profile wow fadeInUp" data-wow-delay="200ms" method="post" id="onSubmitAdd">

    <div class="form-group">
      <label for="nickname"><strong>分类名称</strong></label>
      <input type="text" class="form-control" placeholder="请输入分类名称" id="name" required />
    </div>

    <div class="action">
      <button class="btn">提交</button>
    </div>

  </form>

</body>

</html>
<!-- 解析less的文件 -->
<script src="./assets/js/less.min.js"></script>

<!-- jquery  -->
<script src="./assets/js/jquery.min.js"></script>

<!-- bootstrap -->
<script src="./assets/js/bootstrap.min.js"></script>

<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>

<!-- mui -->
<script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- city-picker -->
<script src="./assets/plugins/city-picker/city-picker.data.min.js"></script>
<script src="./assets/plugins/city-picker/city-picker.min.js"></script>

<!-- 引入接口插件+封装请求的方法 -->
<script src="./assets/plugins/axios/axios.min.js"></script>
<script src="./assets/plugins/axios/request.js"></script>

<!-- bootstrap-validator -->
<script src="./assets/plugins/bootstrap-validator/bootstrapValidator.min.js"></script>

<!-- 引入cookie -->
<script src="./assets/plugins/cookie.js"></script>

<!-- 引入helpers校验用户 -->
<script src="./assets/plugins/helpers.js"></script>

<script>
  //实例化wow.js
  new WOW().init();

  let business = cookie.get("business") ? cookie.get("business") : {};
  console.log(business);
  if (JSON.stringify(business) != '{}') {
    business = JSON.parse(business)
  }
  $("#onSubmitAdd").submit(async function (e) {
    e.preventDefault();
    let result = await POST({
      url: "card/type/add",
      params: {
        businessid: business.id,
        name: $("#name").val()
      }
    })
    console.log(result);


    if (result.code == 1) {
      console.log("请求成功");
      mui.toast(result.msg);
      setTimeout(() => {
        location.href = "typeadd.html"
      }, 2000)
    } else {
      console.log("请求失败");
      mui.toast(result.msg);
    }
  })

  // let business = cookie.get('business') ? cookie.get('business') : {}

  // if (JSON.stringify(business) != '{}') {
  //   business = JSON.parse(business)
  // }

  // $('#onSubmintAdd').submit(async function (e) {
  //   e.preventDefault();

  //   let result = await POST({
  //     url: 'card/type/add', params: {
  //       businessid: business.id,
  //       name: $("#name").val()
  //     }
  //   })

  //   if (result.code == 1) {
  //     mui.toast(result.msg)
  //     setTimeout(() => {
  //       location.href = "typeindex.html"
  //     }, 1000)
  //   } else {
  //     mui.toast(result.msg)
  //   }
  // })
</script>